import java.applet.*; import java.awt.*; import java.awt.geom.*; import javax.swing.*; public class AppTest extends Applet { //data fields (for convenience only) public int xMax; public int yMax; //Initializer - This method is automatically ran with applet is loaded! //It sorta replaces the constructor. public void init() { xMax = getSize().width-1; yMax = getSize().height-1; } //Paint - This method is automatically ran when the applet has to be repainted. public void paint( Graphics g ) { Graphics2D g2D = (Graphics2D) g; //Draw head RoundRectangle2D.Double head = new RoundRectangle2D.Double(0,0,xMax,yMax,50,50); g2D.draw(head); //Draw eyes Ellipse2D.Double leye = new Ellipse2D.Double(100,100,90,50); Ellipse2D.Double reye = new Ellipse2D.Double(310,100,90,50); g2D.draw(leye); g2D.draw(reye); //Draw nose Rectangle2D.Double noseA = new Rectangle2D.Double(225,180,50,100); g2D.fill(noseA); Rectangle2D.Double noseB = new Rectangle2D.Double(220,258,60,20); g2D.fill(noseB); //Draw mouth Ellipse2D.Double mouth = new Ellipse2D.Double(200,350,100,30); g2D.draw(mouth); } }